import { _decorator, Component, Node } from "cc";
import { getGlobal, MyGlobal } from "../Global";
const { ccclass, property } = _decorator;

@ccclass("GameNet")
export class GameNet extends Component {
  dataEventHandler: null;
  roomId: null;
  maxNumOfGames: 0;
  numOfGames: 0;
  numOfMJ: 0;
  seatIndex: -1;
  seats: null;
  turn: -1;
  button: -1;
  dingque: -1;
  chupai: -1;
  isDingQueing: false;
  isHuanSanZhang: false;
  gamestate: "";
  isOver: false;
  dissoveData: null;

  constructor() {
    super();
  }
  start() {}

  update(deltaTime: number) {}
  connectGameServer(data) {
    let g = getGlobal();
    this.dissoveData = null;
    g.socket.ip = data.ip + ":" + data.port;
    let onOk = () => {
      let sd = {
        token: data.token,
        roomid: data.roomid,
        time: data.time,
        sign: data.sign,
      };
      g.socket.send(sd);
    };

    let onFail = () => {};

    g.socket.connect(onOk);
  }
}
